﻿#region Copyright

// All Material Copyright © 2010 Dynamic Concepts Development Corp., All Rights Reserved.
//      Portions Copyright © 1984-2009 Dynamic Concepts Development Corp., All Rights Reserved.
// For further information please contact: SoftwareSupport@dynconcepts.com
// Dynamic Concepts Development Corp.  311 W 57th St. Suite #422, New York, NY 10019

#endregion

#region Using References

using System;
using System.Drawing;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;

#endregion

namespace DynConDevCorp.OpenArch.DynAppFramework.Tiers.UserInterface.WPF.Engine
{
    public class ControlPanelItem
    {
        #region Constructors

        public ControlPanelItem(string title, Bitmap bitmap, ICommandHandler commandHandler)
        {
            Title = title;
            Graphic = Convert(bitmap);
            CommandHandler = commandHandler;
        }

        #endregion

        #region Public Properies and Indexers

        public ICommandHandler CommandHandler { get; private set; }
        public ImageSource Graphic { get; private set; }
        public string Title { get; private set; }

        #endregion

        #region Public Methods

        public static BitmapSource Convert(Bitmap source)
        {
            return Imaging.CreateBitmapSourceFromHBitmap(source.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
                                                         BitmapSizeOptions.FromEmptyOptions());
        }

        #endregion
    }
}